<?php 
include($folder.'/layouts/code-behind/backend.php');
if($_SESSION['id']!==null)
{
	query('INSERT INTO archive (created,subject) VALUES (now(),1)', null);
	header('Content-Type: application/octet-stream'); 
	header('Content-Disposition: attachment; filename="sql_'.date('Y-m-d_Hi').'.gz"');
	$options = array(
		'http' => array(
			'method' => 'GET',
			'header' => 'Authorization: basic '.base64_encode('kincsker:'.$db_password)."\r\n\r\n"			  
		)
	);
	$context = stream_context_create($options);
	$fp = fopen('http://87.229.73.63:2082/getsqlbackup/kincsker_Kincskereso.sql.gz', 'r', false, $context);
	fpassthru($fp);
	fclose($fp);
	exit;
}
?>